<?php

use Illuminate\Routing\Router;

Admin::routes();

Route::group([
    'prefix'     => config('admin.route.prefix'),
    'namespace'  => config('admin.route.namespace'),
    'middleware' => config('admin.route.middleware'),
    'as'         => config('admin.route.prefix') . '.',
], function (Router $router) {
    $router->get('/', 'HomeController@index');
    $router->get('/settings', 'HomeController@settings');
    $router->get('/fjfl', 'EstimateController@index')->name('fjfl');
    $router->get('/fjfl/{id}', 'EstimateController@show')->name('fjfl.show');
    $router->get('/fjfl/{id}/pdf', 'EstimateController@show')->name('fjfl.export');
    //部门
    $router->resource('departments', 'DepartmentController');
    //站点管理
    $router->resource('sites', 'SiteController')->only(['index', 'edit', 'update', 'create', 'store']);

    $router->resource('ossConfigs', 'OssConfigController');

    //代理机构
    $router->resource('agencies', 'AgencyController');

//    //专利评估  申请前评估， 已评估 1，申请中，已授权，评估未通过，
//    //评估中
    $router->resource('patent-lib', 'PatentLibraryController');

    $router->resource('transverses', 'TransverseController');
    $router->any('transverseBills/{id}/change', 'TransverseBillController@change')->name('transverseBills.change');

    $router->resource('contracts', 'TransverseContractController');
    $router->resource('contract-types', 'ContractTypeController');
    $router->get('api/searchUser/{type?}', 'ApiController@searchUser')->name('api.searchUser');
    $router->get('api/participant', 'ApiController@participant')->name('api.participant');

    $router->resource('patents', 'PatentController')->only(['index', 'edit', 'update', 'destroy']);

//    $router->get('patentShou', 'PatentController@index2');

    $router->resource('transactions', 'PatentTransactionController');
    $router->resource('experts', 'ExpertController');

    $router->resource('bookApplies', 'BookApplyController');
    $router->resource('plantVarieties', 'PlantVarietyController');

    $router->resource('documents', 'DocumentController')->only(['index', 'destroy']);
    $router->resource('patent-assesses', 'PatentAssessController')->only(['index', 'destroy']);
    //设置
    $router->group([
        'prefix'    => 'setting',
        'namespace' => 'Setting',
        'as'        => 'setting.',
    ], function (Router $router) {
        $router->resource('technical-fields', 'TechnicalFieldController');
        $router->resource('agencyUsers', 'AgencyUserController');
        $router->resource('expertUsers', 'ExpertUserController');
        $router->resource('documents', 'DocumentController');
    });
    $router->group(['namespace'=>'Patent'], function (Router $router) {
        //专利年费监控
        $router->resource('patentApplies', 'PatentApplyController');
    });
    $router->group(['prefix' => 'patent', 'as' => 'patent.'], function (Router $router) {
        //专利年费监控
        $router->get('pg', 'PatentApplyController@review')->name('pg.review');
        $router->delete('pg/{id}', 'PatentApplyController@destroy');
        $router->get('pg-fail', 'PatentApplyController@fail');
        $router->delete('pg-fail/{id}', 'PatentApplyController@destroy');
        $router->get('pg/download/{id}', 'PatentApplyController@download')->name('pg.download');
        $router->get('pg/preview/{id}', 'PatentApplyController@preview')->name('pg.preview');
        $router->get('apply', 'PatentApplyController@index')->name('apply');
        $router->delete('apply/{id}', 'PatentApplyController@destroy');
        $router->get('publish', 'PatentApplyController@publish')->name('publish');
        $router->delete('publish/{id}', 'PatentApplyController@destroy');

        $router->get('fees', 'PatentFeeController@index')->name('fees.index');
        $router->get('priority', 'PatentMonitorController@priority');
    });
    $router->group(['namespace' => 'Auth'], function (Router $router) {
        $router->resource('auth/menu', 'MenuController'); //管理端菜单
        $router->resource('auth/dept-menu', 'DeptMenuController'); //院系菜单
        $router->resource('auth/user-menu', 'InventorMenuController');//发明人菜单
        $router->resource('auth/expert-menu', 'EvaluationMenuController');//专家菜单
        $router->resource('users', 'AdminUserController');
        //不需要权限
        $router->group(['middleware' => 'admin.permission:free'], function (Router $router) {
            $router->get('auth/setting', 'AuthController@getSetting');
            $router->put('auth/setting', 'AuthController@putSetting');
            $router->post('_handle_form_', 'HandleController@handleForm')->name('admin.handle-form');
            $router->post('_handle_action_', 'HandleController@handleAction')->name('admin.handle-action');
        });
    });

    include_once __DIR__ . '/routes/project.php';
    include_once __DIR__ . '/routes/book.php';
    include_once __DIR__ . '/routes/plant.php';

    require dirname(__DIR__, 2) . '/routes/file.php';

});
